﻿using WebApp.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WebApp.ViewModels.Manage
{
    public class MenuTreeModel
    {
        public enum enmMenuKind
        {
            模块 = 0,
            菜单 = 1,
            功能 = 2
        }

        public int Id { get; set; }
        public string Menukind { get; set; }
        public string Menuid { get; set; }
        public string Menuname_zho { get; set; }
        public string Menuname_eng { get; set; }
        public string Pmenuid { get; set; }
        public int Islastlevel { get; set; }
        public string Orderseq { get; set; }
        public long Menuactions { get; set; }
        public int Showallways { get; set; }
        public string Menuobject { get; set; }
        public string Menuurl { get; set; }
        public string Menuparams { get; set; }
        public string Menuiconsmall { get; set; }
        public string Menuiconmiddle { get; set; }
        public string Menuiconlarge { get; set; }
        public int Iscontextmenu { get; set; }
        public int Istoolbarmenu { get; set; }
        public int Isshortcutmenu { get; set; }
        public int Showtopsep { get; set; }
        public int Showbottomsep { get; set; }
        public string Tag_1 { get; set; }
        public string Tag_2 { get; set; }
        public string Tag_3 { get; set; }
        public string Tag_4 { get; set; }
        public string Tag_5 { get; set; }
        public int Status { get; set; }

        public string Menukindstr { get; set; }
        public string iconCls { get; set; }

        /// <summary>
        /// open/close
        /// </summary>
        public string state { get; set; }

        public List<MenuTreeModel> children { get; set; }

        public MenuTreeModel()
        {

        }

        public MenuTreeModel(S_menu menu)
        {
            this.Id = menu.Id;
            this.Menukind = menu.Menukind;
            this.Menuid = menu.Menuid;
            this.Menuname_zho = menu.Menuname_zho;
            this.Menuname_eng = menu.Menuname_eng;
            this.Pmenuid = menu.Pmenuid;
            this.Islastlevel = menu.Islastlevel;
            this.Orderseq = menu.Orderseq;
            this.Menuactions = menu.Menuactions;
            this.Showallways = menu.Showallways;
            this.Menuobject = menu.Menuobject;
            this.Menuurl = menu.Menuurl;
            this.Menuparams = menu.Menuparams;
            this.Menuiconsmall = menu.Menuiconsmall;
            this.Menuiconmiddle = menu.Menuiconmiddle;
            this.Menuiconlarge = menu.Menuiconlarge;
            this.Iscontextmenu = menu.Iscontextmenu;
            this.Istoolbarmenu = menu.Istoolbarmenu;
            this.Isshortcutmenu = menu.Isshortcutmenu;
            this.Showtopsep = menu.Showtopsep;
            this.Showbottomsep = menu.Showbottomsep;
            this.Tag_1 = menu.Tag_1;
            this.Tag_2 = menu.Tag_2;
            this.Tag_3 = menu.Tag_3;
            this.Tag_4 = menu.Tag_4;
            this.Tag_5 = menu.Tag_5;
            this.Status = menu.Status;

            this.Menukindstr = ((enmMenuKind)Convert.ToInt32(menu.Menukind)).ToString();

            if (menu.Menukind == enmMenuKind.模块.ToString("d"))
            {
                //this.iconCls = "icon-folder-close";
                this.state = "open";
            }
            else if (menu.Menukind == enmMenuKind.菜单.ToString("d"))
            {
                this.iconCls = "icon-crf-field";
                //this.state = "closed";
            }
            else if (menu.Menukind == enmMenuKind.功能.ToString("d"))
            {
                this.iconCls = "icofont-pencil";
                //this.state = "closed";
            }

        }
    }
}
